{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[{\"faceId\": \"4aefbf25-a5e5-4b5a-9791-c1ab40285626\", \"faceRectangle\": {\"top\": 621, \"left\": 616, \"width\": 195, \"height\": 195}, \"faceAttributes\": {\"smile\": 0.0, \"headPose\": {\"pitch\": -11.4, \"roll\": 7.7, \"yaw\": 5.3}, \"gender\": \"male\", \"age\": 30.0, \"facialHair\": {\"moustache\": 0.4, \"beard\": 0.4, \"sideburns\": 0.1}, \"glasses\": \"NoGlasses\", \"emotion\": {\"anger\": 0.0, \"contempt\": 0.0, \"disgust\": 0.0, \"fear\": 0.0, \"happiness\": 0.0, \"neutral\": 0.999, \"sadness\": 0.001, \"surprise\": 0.0}, \"blur\": {\"blurLevel\": \"high\", \"value\": 0.89}, \"exposure\": {\"exposureLevel\": \"goodExposure\", \"value\": 0.51}, \"noise\": {\"noiseLevel\": \"medium\", \"value\": 0.59}, \"makeup\": {\"eyeMakeup\": true, \"lipMakeup\": false}, \"accessories\": [], \"occlusion\": {\"foreheadOccluded\": false, \"eyeOccluded\": false, \"mouthOccluded\": false}, \"hair\": {\"bald\": 0.04, \"invisible\": false, \"hairColor\": [{\"color\": \"black\", \"confidence\": 0.98}, {\"color\": \"brown\", \"confidence\": 0.87}, {\"color\": \"gray\", \"confidence\": 0.85}, {\"color\": \"other\", \"confidence\": 0.25}, {\"color\": \"blond\", \"confidence\": 0.07}, {\"color\": \"red\", \"confidence\": 0.02}, {\"color\": \"white\", \"confidence\": 0.0}]}}}, {\"faceId\": \"315586e7-a738-4f23-a22c-e65c3c6fccc7\", \"faceRectangle\": {\"top\": 693, \"left\": 1503, \"width\": 180, \"height\": 180}, \"faceAttributes\": {\"smile\": 0.003, \"headPose\": {\"pitch\": -9.0, \"roll\": -0.5, \"yaw\": -1.5}, \"gender\": \"female\", \"age\": 60.0, \"facialHair\": {\"moustache\": 0.0, \"beard\": 0.0, \"sideburns\": 0.0}, \"glasses\": \"NoGlasses\", \"emotion\": {\"anger\": 0.0, \"contempt\": 0.001, \"disgust\": 0.0, \"fear\": 0.0, \"happiness\": 0.003, \"neutral\": 0.984, \"sadness\": 0.011, \"surprise\": 0.0}, \"blur\": {\"blurLevel\": \"high\", \"value\": 0.83}, \"exposure\": {\"exposureLevel\": \"goodExposure\", \"value\": 0.41}, \"noise\": {\"noiseLevel\": \"high\", \"value\": 0.76}, \"makeup\": {\"eyeMakeup\": false, \"lipMakeup\": false}, \"accessories\": [], \"occlusion\": {\"foreheadOccluded\": false, \"eyeOccluded\": false, \"mouthOccluded\": false}, \"hair\": {\"bald\": 0.06, \"invisible\": false, \"hairColor\": [{\"color\": \"black\", \"confidence\": 0.99}, {\"color\": \"gray\", \"confidence\": 0.89}, {\"color\": \"other\", \"confidence\": 0.64}, {\"color\": \"brown\", \"confidence\": 0.34}, {\"color\": \"blond\", \"confidence\": 0.07}, {\"color\": \"red\", \"confidence\": 0.03}, {\"color\": \"white\", \"confidence\": 0.0}]}}}]\n"
     ]
    }
   ],
   "source": [
    "import requests\n",
    "import json\n",
    "\n",
    "# set to your own subscription key value\n",
    "subscription_key = '89066c5729ec4449997c1e89c0fbefb8'\n",
    "assert subscription_key\n",
    "\n",
    "# replace <My Endpoint String> with the string from your endpoint URL\n",
    "face_api_url = 'https://api-hly.cognitiveservices.azure.com/face/v1.0/detect'\n",
    "\n",
    "image_url = 'https://upload.wikimedia.org/wikipedia/commons/3/37/Dagestani_man_and_woman.jpg'\n",
    "\n",
    "headers = {'Ocp-Apim-Subscription-Key': '89066c5729ec4449997c1e89c0fbefb8'}\n",
    "\n",
    "params = {\n",
    "    'returnFaceId': 'true',\n",
    "    'returnFaceLandmarks': 'false',\n",
    "    # 可选参数,请仔细阅读API文档\n",
    "    'returnFaceAttributes': 'age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise',\n",
    "}\n",
    "\n",
    "response = requests.post(face_api_url, params=params,\n",
    "                         headers=headers, json={\"url\": image_url})\n",
    "print(json.dumps(response.json()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.6rc1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
